import 'package:flutter/material.dart';
import 'package:flutter_changdian_football/widget/screenutil/custom_screenutil.dart';
import 'package:get/get.dart';

/// 申请资料
class ApplicationInfoDialog {

  static void show(
    BuildContext mContext, {
      Function? confirmTap,
      Function? cancelTap,
      TextEditingController? controller
    }
  ) {
    showDialog(
      barrierDismissible: false,
      context: mContext,
      builder: (BuildContext context) {
        // return ShowDialogPage(
        //   confirmTap: confirmTap,
        //   cancelTap: cancelTap
        // );
        return WillPopScope(
          onWillPop: () async => false,
          child: ShowDialogPage(
            confirmTap: confirmTap,
            cancelTap: cancelTap,
            controller: controller
          ),
        );
      }
    );
  }

}





class ShowDialogPage extends Dialog {
  ShowDialogPage({
    this.confirmTap,
    this.cancelTap,
    this.controller
  });

  // 确认
  final Function? confirmTap;
  final Function? cancelTap;

  final TextEditingController? controller;

  @override
  Widget build(BuildContext dContext) {
    return Material(
      //创建透明层
      type: MaterialType.transparency, //透明类型
      //自定义dialog布局
      child: Center(
        child: RichText(
          text: TextSpan(
            children: [
              WidgetSpan(
                child: Column(
                  mainAxisSize: MainAxisSize.min,
                  children: [
                    Container(
                      margin: EdgeInsets.symmetric(horizontal: 40.w),
                      padding: EdgeInsets.only(top: 26.w, left: 20.w, right: 20.w, bottom: 20.w),
                      width: double.infinity,
                      decoration: BoxDecoration(
                        color: Colors.white,
                        borderRadius: BorderRadius.circular(12.r)
                      ),
                      child: Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        mainAxisSize: MainAxisSize.min,
                        children: [
                          Container(
                            alignment: Alignment.center,
                            child: Text('申请资料', style: TextStyle(fontSize: 18.sp, fontWeight: FontWeight.w500, color: const Color(0xff323232)),),
                          ),

                          SizedBox(height: 20.w,),

                          SizedBox(
                            child: Row(
                              children: [
                                Expanded(
                                  child: Container(
                                    decoration: BoxDecoration(
                                      color: const Color(0xffF2F2F2).withOpacity(0.8),
                                      borderRadius: BorderRadius.circular(8.r),
                                    ),
                                    child: TextField(
                                      controller: controller,
                                      textAlign: TextAlign.start,
                                      textInputAction: TextInputAction.done,
                                      maxLines: 8,
                                      decoration: InputDecoration(
                                        contentPadding: EdgeInsets.symmetric(vertical: 10.w, horizontal: 16.w),
                                        isCollapsed: true,
                                        border: InputBorder.none,
                                        hintStyle: TextStyle(fontSize: 14.sp, color: const Color(0xffBFBFBF), height: 1.5),
                                        hintText: '请简述您的个人信息，以便球队负责人审核；\n\n1、踢球频率\n2、踢球时间\n3、大致水平\n4、踢球目标（目的）',
                                        counterText: '',
                                      ),
                                      style: TextStyle(fontSize: 14.sp, color: const Color(0xff333333), height: 1.5),
                                    ),
                                  ),
                                ),
                              ],
                            ),
                          ),

                          SizedBox(height: 20.w,),

                          SizedBox(
                            child: Row(
                              children: [
                                Expanded(
                                  child: GestureDetector(
                                    behavior: HitTestBehavior.translucent,
                                    onTap: () {
                                      cancelTap?.call();
                                    },
                                    child: Container(
                                      padding: EdgeInsets.symmetric(vertical: 12.w),
                                      decoration: BoxDecoration(
                                        borderRadius: BorderRadius.circular(8.r),
                                        border: Border.all(
                                          width: 1.w,
                                          color: const Color(0xff999999)
                                        )
                                      ),
                                      alignment: Alignment.center,
                                      child: Text('取消', style: TextStyle(fontSize: 14.sp, color: const Color(0xff999999), fontWeight: FontWeight.w500),),
                                    ),
                                  ),
                                ),
                                SizedBox(width: 18.w,),
                                Expanded(
                                  child: GestureDetector(
                                    behavior: HitTestBehavior.translucent,
                                    onTap: () {
                                      confirmTap?.call();
                                    },
                                    child: Container(
                                      padding: EdgeInsets.symmetric(vertical: 12.w),
                                      decoration: BoxDecoration(
                                        color: const Color(0xff499360),
                                        borderRadius: BorderRadius.circular(8.r),
                                        border: Border.all(
                                          width: 1.w,
                                          color: const Color(0xff499360)
                                        )
                                      ),
                                      alignment: Alignment.center,
                                      child: Text('提交', style: TextStyle(fontSize: 14.sp, color: Colors.white, fontWeight: FontWeight.w500),),
                                    ),
                                  ),
                                )
                              ],
                            ),
                          ),
                        ],
                      ),
                    ),

                    SizedBox(height: 60.w,),

                    GestureDetector(
                      behavior: HitTestBehavior.translucent,
                      onTap: () {
                        Get.back();
                      },
                      child: Container(
                        width: 35.w,
                        height: 35.w,
                        decoration: BoxDecoration(
                          border: Border.all(
                            width: 1.5.w,
                            color: const Color(0xffFFFFFF)
                          ),
                          borderRadius: BorderRadius.circular(35.r)
                        ),
                        child: const Icon(Icons.close, color: Colors.white,),
                      ),
                    )
                  ],
                )
              ),
            ]
          ),
        ),
      )
    );
  }
}



